package com.my.mvpdemo.mvp1.presenter;

import com.my.mvpdemo.Girl;
import com.my.mvpdemo.mvp1.model.GirlModelImp1;
import com.my.mvpdemo.mvp1.model.GirlModelImpV2;
import com.my.mvpdemo.mvp1.model.IGirlModel;
import com.my.mvpdemo.mvp1.view.IGirlView;

import java.util.List;

/**
 * Created by 张英杰 on 2017/2/22.
 * 表示层 model和view 的桥梁
 */
public class GirlPresenter {

    //View引用
    IGirlView mGirlView;
    //Model引用
//    IGirlModel girlModel=new GirlModelImp1();
    IGirlModel girlModel=new GirlModelImpV2();

    public GirlPresenter(IGirlView mGirlView) {
        this.mGirlView = mGirlView;
    }

    //加载数据  n取来
    public void fetch(){
        //显示进度条
        if (mGirlView!=null){
            mGirlView.showLoading();
        }
        if (girlModel!=null){
            //加载数据
            girlModel.loadGirl(new IGirlModel.GirlOnLoadListerer() {
                @Override
                public void onComplete(List<Girl> girls) {
                    //返回数据
                    //显示到view层
                    mGirlView.showGirls(girls);
                }
            });
        }
    }
}
